/**
 * Minder.java
 * com.sftz.modules.minapp.minder.module
 * Copyright (c) 2018, 北京科技有限公司版权所有.
*/

package com.sftz.modules.web.minder.module;

import java.util.HashMap;
import java.util.Map;

import org.nutz.dao.Cnd;
import org.nutz.dao.SqlManager;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

import com.sftz.assets.entities.InsResourceDataEntity;
import com.sftz.modules.web.minder.form.MinderForm;
import com.uxuexi.core.common.util.Util;
import com.uxuexi.core.db.dao.IDbDao;

/**
 * @author   闫志彬
 * @Date	 2018年12月20日 	 
 */
@IocBean
@At("/web/minder/")
@Filters
public class Minder {

	@Inject
	private IDbDao dbDao;

	@Inject
	private SqlManager sqlManager;

	@At
	@Ok("jsp")
	public Object minder(@Param("..") final MinderForm minderForm) {
		Integer minderId = minderForm.getId();
		if (Util.isEmpty(minderId)) {
			throw new IllegalArgumentException("参数id不能为空");
		} else {
			return minderId;
		}
	}

	@At
	@Ok("json")
	public Object getMinderInfor(@Param("..") final MinderForm minderForm) {
		Map<String, Object> obj = new HashMap<String, Object>();
		Integer minderId = minderForm.getId();
		if (Util.isEmpty(minderId)) {
			throw new IllegalArgumentException("参数id不能为空");
		} else {
			InsResourceDataEntity insResourceData = dbDao.fetch(InsResourceDataEntity.class,
					Cnd.where("courseStructureId", "=", minderId));
			obj.put("insResourceData", insResourceData);
		}
		return obj;
	}

}
